
On Error Resume Next
strComputer = "."
targetProcess = "php.exe"

' 方法1：WMI查询终止
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * From Win32_Process Where Name='" & targetProcess & "'")

For Each objProcess in colProcesses
    ret = objProcess.Terminate()
    If ret = 0 Then 
        WScript.Echo "killed PID:" & objProcess.ProcessId
    Else
        WScript.Echo "failed to kill PID:" & objProcess.ProcessId
    End If
Next

' 方法2：taskkill命令终止（备用方案）
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "taskkill /f /im " & targetProcess, 0, True
